<?
require("config.php");

require($rela_path . "bin/country.php");

$location_status .= " | Delete";

$show_backnav = "order_menu";

$menutype = 2;


if (!checkRecord($table,$id)){

	header("location:" . $rela_path . "share/msg.php?v=9002");
	exit();

}


$Query = "SELECT 
	no,
	trans_no,
	purchase_date,
	member_code,
	member_name,
	member_email,
	recipient_title,
	recipient_name,
	recipient_email,
	shipping_carrier,
	shipping_region,
	hkid,
	recipient_address,
	recipient_country,
	recipient_zip,
	recipient_tel,
	recipient_mobile,
	billing_address,
	billing_country,
	billing_zip,
	order_status,
	shipping_status,
	delivery_date
FROM $table WHERE id=$id";

$r = myQuery($Query);

	$no					=	$r[0][0];
	$trans_no			=	$r[0][1];
	$purchase_date		=	$r[0][2];
	$member_code		=	$r[0][3];
	$member_name		=	$r[0][4];
	$member_email		=	$r[0][5];
	$recipient_title	=	$r[0][6];
	$recipient_name		=	$r[0][7];
	$recipient_email	=	$r[0][8];
	$shipping_carrier	=	$r[0][9];
	$shipping_region	=	$r[0][10];
	$hkid				=	$r[0][11];
	$recipient_address	=	$r[0][12];
	$recipient_country	=	$r[0][13];
	$recipient_zip		=	$r[0][14];
	$recipient_tel		=	$r[0][15];
	$recipient_mobile	=	$r[0][16];
	$billing_address	=	$r[0][17];
	$billing_country	=	$r[0][18];
	$billing_zip		=	$r[0][19];
	$order_status		=	$r[0][20];
	$shipping_status	=	$r[0][21];
	$delivery_date		=	$r[0][22];
	
	$sql="select mobile from cus_info where id = $member_code";
$m=myQuery($sql);
$mobile=$m[0][0];



if (NULL!=$action){

   $Query = "delete from $table where id=$id LIMIT 1";

   myQuery($Query);

   $Query = "delete from $table1 where no='$no'";

   myQuery($Query);


   header("location:" . $rela_path . "share/msg.php?v=27");

   exit();

}

/*//Currency
$Query = "SELECT currency FROM cus_basic WHERE contact='$Contact' AND company='$Company' LIMIT 1";
$c=myQuery($Query);

if (!$c) {
	$currency="usd";
}else{
	$currency = $c[0][0];
}
*/

require($rela_path . "inc/header.php");

?>

<form action="" method="post" name="form1">  
<br>
<!--hidden filed-->
<input name="action" type="hidden" value="delete">
<input name="id" type="hidden" value="<?print($id)?>">
<input name="Code" type="hidden" value="<?print($Code)?>">
<table width="95%" border="0" align="center">
  <tr> 
    <td width="579" valign="top" height="143"> Are you sure to delete this order 
      ? 
      <input type="submit" class="button" name="Submit" value="   Yes   "> 
      <input type="button" class="button" name="Submit2" value="   No   " onClick="Redirect('order_menu.php',1)"> 
      <br>
      <br>
      <br>
      <table border="0" cellspacing="0" cellpadding="2">
        <tr> 
          <td width="592"><table border="0" cellspacing="0" cellpadding="2">
            <tr>
              <td class="tdheader">No :</td>
              <td>
                <?=str_pad($no,10,'0',STR_PAD_LEFT)?>
              </td>
            </tr>
            <tr>
              <td class="tdheader">Transaction No :</td>
              <td>
                <?=$trans_no?>
              </td>
            </tr>
            <tr>
              <td class="tdheader">Purchase Date :</td>
              <td>
                <?=date('Y-m-d',$purchase_date)?>
              </td>
            </tr>
            <tr>
              <td class="tdheader">Member Code :</td>
              <td>
                <?=$member_code?>
              </td>
            </tr>
            <tr>
              <td class="tdheader">Member Name :</td>
              <td>
                <?=$member_name?>
              </td>
            </tr>
            <tr>
              <td class="tdheader">Member Email : </td>
              <td><?=$member_email?></td>
            </tr>
            <tr>
              <td class="tdheader">&nbsp;</td>
              <td> </td>
            </tr>
            <tr bgcolor="#CCCCCC">
              <td colspan="2" class="tdheader">Recipient Details </td>
            </tr>
            <tr>
              <td class="tdheader">Title :</td>
              <td><?=$recipient_title?></td>
            </tr>
            <tr>
              <td class="tdheader">Recipient Name : </td>
              <td><?=$recipient_name?></td>
            </tr>
            <tr>
              <td class="tdheader">Contact Email : </td>
              <td><?=$recipient_email?></td>
            </tr>
            <tr>
              <td class="tdheader">&nbsp;</td>
              <td></td>
            </tr>
            <tr>
              <td colspan="2" bgcolor="#CCCCCC" class="tdheader">Delivery Method </td>
            </tr>
            <tr>
              <td class="tdheader">Shipping Carrier: </td>
              <td><?=$shipping_carrier?></td>
            </tr>
            <tr>
              <td class="tdheader">Shipping Region: </td>
              <td><?=$shipping_region?></td>
            </tr>
            <tr>
              <td class="tdheader">HK ID# : </td>
              <td><?=$hkid?></td>
            </tr>
            <tr>
              <td class="tdheader">&nbsp;</td>
              <td></td>
            </tr>
            <tr>
              <td colspan="2" bgcolor="#CCCCCC" class="tdheader">Delivery Address </td>
            </tr>
            <tr>
              <td class="tdheader">Recipient's Address : </td>
              <td><?=$recipient_address?></td>
            </tr>
            <tr>
              <td class="tdheader">Country : </td>
              <td><?=$recipient_country?></td>
            </tr>
            <tr>
              <td class="tdheader">Zipcode : </td>
              <td><?=$recipient_zip?></td>
            </tr>
            <tr>
              <td class="tdheader">Contact Phone : </td>
              <td><?=$recipient_tel?></td>
            </tr>
            <tr>
              <td class="tdheader">Mobile / Pager : </td>
              <td><?=$mobile?></td>
            </tr>
            <tr>
              <td class="tdheader">&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td colspan="2" bgcolor="#CCCCCC" class="tdheader">Billing Address </td>
            </tr>
            <tr>
              <td class="tdheader">Billing Address :</td>
              <td><?=$billing_address?></td>
            </tr>
            <tr>
              <td class="tdheader">Country : </td>
              <td><?=$billing_country?></td>
            </tr>
            <tr>
              <td class="tdheader">Zipcode :</td>
              <td><?=$billing_zip?></td>
            </tr>
            <tr>
              <td class="tdheader">&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td class="tdheader">Order Status :</td>
              <td><?=$order_status?></td>
            </tr>
            <tr>
              <td class="tdheader">Shipping Status:</td>
              <td><?=$shipping_status?></td>
            </tr>
            <tr>
              <td class="tdheader">Delivery Date : </td>
              <td><?=date('Y-m-d',$delivery_date)?></td>
            </tr>
          </table> 

<?
$Query = "SELECT 
no,
pro_code,
pro_name,
pro_color,
pro_size,
unit_price,
qty 
FROM $table1 WHERE no='$no'";
$r=myQuery($Query);

?>


        <table width="95%" border="0" cellpadding="0" cellspacing="1" class="tb">
          <tr class="tbheader"> 
            <td> <div align="center">No.</div></td>
            <td> <div align="center">Product Code</div></td>
            <td> <div align="center">Product Name</div></td>
            <td> <div align="center">Unit Price</div></td>
            <td> <div align="center">Qty</div></td>
            <td> <div align="center">Amount</div></td>
          </tr>

<?
$total_qty = 0;
$total_price = 0;
	

	for ($i=0;$i<count($r);$i++){
	
	$subtotal = $r[$i][5]*$r[$i][6];
	$total_qty += $r[$i][6];
	$total_price += $subtotal;
	?>
          <tr class="tbcontent1"> 
            <td><?print($i+1)?></td>
            <td><?print($r[$i][1])?></td>
            <td><?print($r[$i][2])?></td>
            <td> <div align="right"><?print($r[$i][5])?></div></td>
            <td> <div align="right"><?print($r[$i][6])?></div></td>
            <td> <div align="right"><?print(Number_format($subtotal,2))?></div></td>
          </tr>
<?}?>



          <tr> 
            <td colspan="6" class="tbcontent1" height=30><div align="right"><b>Total Amount : <?print("($currency)" . Number_format($total_price,2))?></b></div></td>
          </tr>
        </table>


          </td>
        </tr>
      </table>
      <br>
      <br>
    </td>

  </tr>
</table>

</form>

<br>
<br>
<br>
<?
require($rela_path . "inc/footer.php");
?>
